package scalab.core.component

//import scalab.core.Dependency
import scalab.core.dependencies.Dependency
trait Mapper extends Filter{

	val in = mandatoryIn
	
	def execute: Boolean = {
		transmit(in.sources map {d => map(d)})
		returnValue
	}

	def map(d: Dependency): Dependency

	def instanceId: String = ""
	def returnValue: Boolean = true
}

object Mapper{
	def apply(componentName: String, mapper: (Dependency => Dependency)): Mapper = new Mapper{
		override def map(d: Dependency): Dependency = mapper(d)
		override val name: String = componentName
	}

	def apply(mapper: (Dependency => Dependency)): Mapper = apply("Mapper", mapper)
}
